<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/3
 * Time: 11:31
 */

namespace app\controllers;


use yii;
use \app\models\PrintModel;

class PrintController extends ApiBaseController
{
    public function actionUpdate()
    {
        if (!yii::$app->request->isPost) {
            return \json_encode(['code' => 0, 'msg' => 'not allowed']);
        }
        $id = yii::$app->request->post('id');
        $model = new PrintModel();
        $re = $model->one(['id' => $id]);
        if ($re['lock_status'] == 1) {
            return json_encode(['code' => 0, 'msg' => '已被锁定无法修改']);

        }
        $param = yii::$app->request->post('param');
        $value = yii::$app->request->post('value');
        $data = [];
        $data['last_modify'] = $this->user['job_number'];
        $data['last_modify_time'] = time();
        $data[$param] = $value;
        $re = $model->save($data, ['id' => $id]);
        if ($re) {
            echo json_encode(['code' => 1, 'msg' => '修改成功']);
        } else {
            echo json_encode(['code' => 0, 'msg' => '修改失败，请重试']);
        }

    }
}